#include "../views.hpp"


using lms::views::MainView;
using lms::views::MaintenancesView;
using lms::views::TurnView;

MainView::MainView() {

  maintenance = new MaintenancesView();
  option = 0;

}

void MainView::show() {

  TurnView* turnView = new TurnView();
  OrderView* orderView = new OrderView();
  do {

    Utilities::clearScreen();

    Utilities::printText("\t\t\tWelcome To Library Management System\n");
    Utilities::printText("\t1. Managements\n");
    Utilities::printText("\t2. Books Shop\n");
    Utilities::printText("\t3. Turn Registration\n");
    Utilities::printText("\t4. Exit\n");
    
    option = Utilities::reinterpret_input<int>("\tChoose An Option: ");


    switch (option) {
      case 1:
        maintenance->show();
        break;
      case 2:

          if( (turnView->getQueueCustomers())->getLength() >0 )
          {
                orderView->setCustomersEnQueue( turnView->getQueueCustomers() );
                orderView->mainMenu();
          }
        break;
      case 3:
        turnView->show();        
        break;
        
        case 4:
            break;
        default:
            Utilities::printText("\tInvalid Option\n");
            Utilities::pause();
            break;
    }
  } while (option != 4);
}
